class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        s = self.getIsomorphic(s)
        t = self.getIsomorphic(t)
        return s == t

    def getIsomorphic(self, s):
        id = 0
        ids = [0] * len(s)
        dic = {}
        for i in range(len(s)):
            if s[i] not in dic:
                dic[s[i]] = str(id)
                id = id + 1
            ids[i] = dic[s[i]]
        return "".join(ids)


if __name__ == '__main__':
    so = Solution()
    s = "egg"
    t = "adc"
    r = so.isIsomorphic(s, t)
    print(r)
